﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Billing.DataObjects;

namespace Billing.Transactions
{
    public partial class UncommitedPaymentTransfersForm : Billing.WindowsBase.BaseList
    {
        public UncommitedPaymentTransfersForm()
        {
            InitializeComponent();
        }
        BillingDataContext mBillingDataContext;
        public BillingDataContext BillingDataContext
        {
            get
            {
                if (mBillingDataContext == null)
                    mBillingDataContext = new BillingDataContext();
                return mBillingDataContext;
            }
            set { mBillingDataContext = value; }
        }
        protected override void onDataLoad()
        {
            base.onDataLoad();
            this.bsElement.DataSource = this.BillingDataContext.GetUncommitedCashPayments(this.dtFrom.DateTime, this.dtTo.DateTime);

        }
        protected override void onElementInitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
            base.onElementInitializeLayout(sender, e);
            this.ElementNameID = "ID";

            e.Layout.Bands[0].Columns["ID"].Header.VisiblePosition = 0;
            e.Layout.Bands[0].Columns["ID"].Width = 60;
            e.Layout.Bands[0].Columns["DocumentDate"].Header.VisiblePosition = 1;
            e.Layout.Bands[0].Columns["DocumentDate"].Width = 70;
            e.Layout.Bands[0].Columns["DocumentDate"].Header.Caption = "თარიღი";
            e.Layout.Bands[0].Columns["DocumentDate"].Format = "dd.MM.yyyy";
            e.Layout.Bands[0].Columns["DocumentNumber"].Header.VisiblePosition = 2;
            e.Layout.Bands[0].Columns["DocumentNumber"].Width = 60;
            e.Layout.Bands[0].Columns["DocumentNumber"].Header.Caption = "დოკ. ნომერი";
            e.Layout.Bands[0].Columns["Amount"].Header.VisiblePosition = 3;
            e.Layout.Bands[0].Columns["Amount"].Width = 50;
            e.Layout.Bands[0].Columns["Amount"].Header.Caption = "თანხა";
            e.Layout.Bands[0].Columns["Amount"].Format = "#,##0.00";
            e.Layout.Bands[0].Columns["ClientID"].Header.VisiblePosition = 4;
            e.Layout.Bands[0].Columns["ClientID"].Width = 70;
            e.Layout.Bands[0].Columns["ClientID"].Header.Caption = "კლიენტის #";
            e.Layout.Bands[0].Columns["IdentificationNumber"].Header.VisiblePosition = 5;
            e.Layout.Bands[0].Columns["IdentificationNumber"].Width = 130;
            e.Layout.Bands[0].Columns["IdentificationNumber"].Header.Caption = "ს/კ";
            e.Layout.Bands[0].Columns["PaymentPointName"].Header.VisiblePosition = 6;
            e.Layout.Bands[0].Columns["PaymentPointName"].Width = 115;
            e.Layout.Bands[0].Columns["PaymentPointName"].Header.Caption = "გადახდის წერტილი";
            e.Layout.Bands[0].Columns["CreatedDate"].Header.VisiblePosition = 7;
            e.Layout.Bands[0].Columns["CreatedDate"].Width = 115;
            e.Layout.Bands[0].Columns["CreatedDate"].Header.Caption = "შეიქმნა";
            e.Layout.Bands[0].Columns["CreatedDate"].Format = "dd.MM.yyyy hh:mm:ss";
        }

        protected override void onSave()
        {
            try
            {
            this.BillingDataContext.CashDeskPay(null, this.getCurrentElementRowID, null, global::Billing.Profile.UserName);

            }
            catch (Exception ex)
            {

                ShowInformation(ex.Message);
            }

        }
    }
}
